/**
* Created by wust on 2019/10/25.
*/
<template>
  <div>
    <el-divider content-position="center"><b>{{detailModel.title}}</b></el-divider>
    <div style="text-align: center;font-size: 10px;">发布者：{{detailModel.createrName}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;发布时间：{{detailModel.createTime | formatDate('yyyy-MM-dd hh:mm:ss')}}</div>
    <el-timeline v-if="detailModel.type == 'A102108'">
      <el-timeline-item :timestamp="data.timestamp" placement="top" v-for="(data, index) in timelineData" :key="index"
        color="#0bbd87">
        <el-card>
          <el-tag v-if="data.type == 'A103102'" type="success" effect="light">
            {{data.typeLabel }}
          </el-tag>
          <el-tag v-else-if="data.type == 'A103101'" type="danger" effect="light">
            {{data.typeLabel }}
          </el-tag>
          <p>{{data.description}}</p>
        </el-card>
      </el-timeline-item>
    </el-timeline>
    <p v-if="detailModel.type != 'A102108'" v-html="detailModel.content" style="width:100%;height:100%;overflow:scroll;"></p>
  </div>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'my-notice-detail',
  props: ['selectedModel'],
  data () {
    return {
      detailModel: {
        notificationId: null,
        title: '',
        content: '',
        priorityLevelLabel: '',
        type: ''
      },
      timelineData: {}
    }
  },
  created: function () {
    this.detailModel = this.selectedModel
    this.readMyNotice()
  },
  methods: {
    readMyNotice: function () {
      Vue.$ajax({
        method: 'post',
        url: Vue.$adminServerURL + '/web/v1/MyNoticeController/detail/' + this.detailModel.notificationId
      }).then(res => {
        if (res.data.flag !== 'SUCCESS') {
          if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
            this.$message({
              message: res.data.message,
              type: 'warning'
            })
          }
        } else {
          this.timelineData = res.data.obj
        }
      })
    }
  }
}
</script>
